﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Qu.SeniorProject.Model;

namespace Qu.SeniorProject.WebUI.Controllers
{
    public class ScheduleController : Controller
    {

        public ActionResult Index(string id)
        {
            string gender = string.Empty;
            if (!string.IsNullOrEmpty(id) && id.Equals("f", StringComparison.InvariantCultureIgnoreCase))
                gender = "F";
            else
                if (!string.IsNullOrEmpty(id) && id.Equals("m", StringComparison.InvariantCultureIgnoreCase))
                    gender = "M";

            if (Request.IsAuthenticated && string.IsNullOrEmpty(id))
            {
                var userInfo = Session["UserInfo"] as UserInfo;
                if (userInfo != null && userInfo.IsStudent)
                    gender = userInfo.Gender;

            }

            ViewBag.Message = "CSE Senior Project Presentations Schedule";
            var projectPresentations = ProjectRepository.GetPresentationsSchedule(gender);

            if (projectPresentations == null || projectPresentations.Count == 0)
                ViewBag.NotFoundMessage = "Thanks for your interest! No schedule available. Please stay tuned in for information regarding the senior project presentations schedule.";

            return View("Schedule", projectPresentations);
        }

    }
}
